<template>
  <div id="login">
    <div class="body">
      <div class="top">
        <p>密码登录</p>
      </div>
      <div class="input">
        <el-form :model="formInline" class="demo-form-inline">
          <el-form-item>
            <el-input v-model="formInline.username" />
          </el-form-item>
          <el-form-item>
            <el-input v-model="formInline.pass" show-password />
          </el-form-item>
          <el-form-item>
            <el-button type="danger" @click="logins">登录</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive } from 'vue'
import { login } from '../api/loging'
import { useLOGINStore } from '../stores/loggin' //pinia
import router from '@/router';

const formInline = reactive({
  username: 'admin',
  pass: 'admin'
})
const logins = async () => {
  let res:any = await login(formInline)
  console.log(res)
  if(res.errCode===10000){
    const userloginstore = useLOGINStore()
    userloginstore.token = res.data.token
    userloginstore.menu = res.data.menu 
    router.push('/fkmmanage')
  }
}

</script>

<style lang="less" scoped>
@import '../assets/css/login.less';
</style>
